<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="PHP," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="本文内容来自PHP手册

运算符是可以通过给出的一或多个值（用编程行话来说，表达式）来产生另一个值（因而整个结构成为一个表达式）的东西。
运算符可按照其能接受几个值来分组。一元运算符只能接受一个值，例如 !（逻辑取反运算符）或 ++（递增运算符）。 二元运算符可接受两个值，例如熟悉的算术运算符 +（加）和 -（减），大多数 PHP 运算符都是这种。最后是唯一的三元运算符 ? :，可接受三个值；通">
<meta property="og:type" content="article">
<meta property="og:title" content="PHP运算符">
<meta property="og:url" content="http://yoursite.com/2017/05/16/PHP运算符/index.html">
<meta property="og:site_name" content="EasyBlog">
<meta property="og:description" content="本文内容来自PHP手册

运算符是可以通过给出的一或多个值（用编程行话来说，表达式）来产生另一个值（因而整个结构成为一个表达式）的东西。
运算符可按照其能接受几个值来分组。一元运算符只能接受一个值，例如 !（逻辑取反运算符）或 ++（递增运算符）。 二元运算符可接受两个值，例如熟悉的算术运算符 +（加）和 -（减），大多数 PHP 运算符都是这种。最后是唯一的三元运算符 ? :，可接受三个值；通">
<meta property="og:image" content="http://yoursite.com/uploads/运算符优先级一.jpg">
<meta property="og:image" content="http://yoursite.com/uploads/运算符优先级二.jpg">
<meta property="og:image" content="http://yoursite.com/uploads/算术运算符.png">
<meta property="og:image" content="http://yoursite.com/uploads/位运算符.png">
<meta property="og:image" content="http://yoursite.com/uploads/比较运算符.png">
<meta property="og:image" content="http://yoursite.com/uploads/比较多种类型.png">
<meta property="og:image" content="http://yoursite.com/uploads/递增递减运算符.png">
<meta property="og:image" content="http://yoursite.com/uploads/逻辑运算符.png">
<meta property="og:image" content="http://yoursite.com/uploads/数组运算符.png">
<meta property="og:updated_time" content="2017-06-06T08:57:32.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="PHP运算符">
<meta name="twitter:description" content="本文内容来自PHP手册

运算符是可以通过给出的一或多个值（用编程行话来说，表达式）来产生另一个值（因而整个结构成为一个表达式）的东西。
运算符可按照其能接受几个值来分组。一元运算符只能接受一个值，例如 !（逻辑取反运算符）或 ++（递增运算符）。 二元运算符可接受两个值，例如熟悉的算术运算符 +（加）和 -（减），大多数 PHP 运算符都是这种。最后是唯一的三元运算符 ? :，可接受三个值；通">
<meta name="twitter:image" content="http://yoursite.com/uploads/运算符优先级一.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/05/16/PHP运算符/"/>





  <title> PHP运算符 | EasyBlog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?07a6d49ae67fe991e0ce3c2f3955e0f9";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">EasyBlog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description"></h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/05/16/PHP运算符/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Gasbylei">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://gasbylei.github.io/uploads/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="EasyBlog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                PHP运算符
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-16T18:14:25+08:00">
                2017-05-16
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/05/16/PHP运算符/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count" data-disqus-identifier="2017/05/16/PHP运算符/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>本文内容来自<a href="http://php.net/manual/zh/language.operators.php" target="_blank" rel="external">PHP手册</a></p>
</blockquote>
<p>运算符是可以通过给出的一或多个值（用编程行话来说，表达式）来产生另一个值（因而整个结构成为一个表达式）的东西。</p>
<p>运算符可按照其能接受几个值来分组。一元运算符只能接受一个值，例如 !（逻辑取反运算符）或 ++（递增运算符）。 二元运算符可接受两个值，例如熟悉的算术运算符 +（加）和 -（减），大多数 PHP 运算符都是这种。最后是唯一的三元运算符 ? :，可接受三个值；通常就简单称之为“三元运算符”（尽管称之为条件运算符可能更合适）。</p>
<h3 id="运算符优先级"><a href="#运算符优先级" class="headerlink" title="运算符优先级"></a>运算符优先级</h3><p>运算符优先级指定了两个表达式绑定得有多“紧密”。例如，表达式 1 + 5 <em> 3 的结果是 16 而不是 18 是因为乘号（“</em>”）的优先级比加号（“+”）高。必要时可以用括号来强制改变优先级。例如：(1 + 5) * 3 的值为 18。</p>
<p>如果运算符优先级相同，那运算符的结合方向决定了该如何运算。例如，”-“是左联的，那么 1 - 2 - 3 就等同于 (1 - 2) - 3 并且结果是 -4. 另外一方面，”=”是右联的，所以 $a = $b = $c 等同于 $a = ($b = $c)。</p>
<p>没有结合的相同优先级的运算符不能连在一起使用，例如 1 &lt; 2 &gt; 1 在PHP是不合法的。但另外一方面表达式 1 &lt;= 1 == 1 是合法的, 因为 == 的优先级低于 &lt;=。</p>
<p>括号的使用，哪怕在不是必要的场合下，通过括号的配对来明确标明运算顺序，而非靠运算符优先级和结合性来决定，通常能够增加代码的可读性。</p>
<p>运算符优先级<br><img src="/uploads/运算符优先级一.jpg" alt="运算符优先级1"><br><img src="/uploads/运算符优先级二.jpg" alt="运算符优先级2"></p>
<a id="more"></a>
<p>Example #1 结合方向</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$a = <span class="number">3</span> * <span class="number">3</span> % <span class="number">5</span>; <span class="comment">// (3 * 3) % 5 = 4</span></div><div class="line"><span class="comment">// ternary operator associativity differs from C/C++</span></div><div class="line">$a = <span class="keyword">true</span> ? <span class="number">0</span> : <span class="keyword">true</span> ? <span class="number">1</span> : <span class="number">2</span>; <span class="comment">// (true ? 0 : true) ? 1 : 2 = 2</span></div><div class="line"></div><div class="line">$a = <span class="number">1</span>;</div><div class="line">$b = <span class="number">2</span>;</div><div class="line">$a = $b += <span class="number">3</span>; <span class="comment">// $a = ($b += 3) -&gt; $a = 5, $b = 5</span></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="算术运算符"><a href="#算术运算符" class="headerlink" title="算术运算符"></a>算术运算符</h3><p><img src="/uploads/算术运算符.png" alt="算术运算符"></p>
<p>除法运算符总是返回浮点数。只有在下列情况例外：两个操作数都是整数（或字符串转换成的整数）并且正好能整除，这时它返回一个整数。</p>
<p>取模运算符的操作数在运算之前都会转换成整数（除去小数部分）。</p>
<p>取模运算符 % 的结果和被除数的符号（正负号）相同。即 $a % $b 的结果和 $a 的符号相同。例如：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"></div><div class="line"><span class="keyword">echo</span> (<span class="number">5</span> % <span class="number">3</span>).<span class="string">"\n"</span>;           <span class="comment">// prints 2</span></div><div class="line"><span class="keyword">echo</span> (<span class="number">5</span> % <span class="number">-3</span>).<span class="string">"\n"</span>;          <span class="comment">// prints 2</span></div><div class="line"><span class="keyword">echo</span> (<span class="number">-5</span> % <span class="number">3</span>).<span class="string">"\n"</span>;          <span class="comment">// prints -2</span></div><div class="line"><span class="keyword">echo</span> (<span class="number">-5</span> % <span class="number">-3</span>).<span class="string">"\n"</span>;         <span class="comment">// prints -2</span></div><div class="line"></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="赋值运算符"><a href="#赋值运算符" class="headerlink" title="赋值运算符"></a>赋值运算符</h3><p>基本的赋值运算符是“=”。一开始可能会以为它是“等于”，其实不是的。它实际上意味着把右边表达式的值赋给左边的运算数。</p>
<p>赋值运算表达式的值也就是所赋的值。也就是说，“$a = 3”的值是 3。</p>
<p>在基本赋值运算符之外，还有适合于所有二元算术，数组集合和字符串运算符的“组合运算符”，这样可以在一个表达式中使用它的值并把表达式的结果赋给它，例如</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"></div><div class="line">$a = <span class="number">3</span>;</div><div class="line">$a += <span class="number">5</span>; <span class="comment">// sets $a to 8, as if we had said: $a = $a + 5;</span></div><div class="line">$b = <span class="string">"Hello "</span>;</div><div class="line">$b .= <span class="string">"There!"</span>; <span class="comment">// sets $b to "Hello There!", just like $b = $b . "There!";</span></div><div class="line"></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>注意赋值运算将原变量的值拷贝到新变量中（传值赋值），所以改变其中一个并不影响另一个。这也适合于在密集循环中拷贝一些值例如大数组。</p>
<p>在 PHP 中普通的传值赋值行为有个例外就是碰到对象 object 时，在 PHP 5 中是以引用赋值的，除非明确使用了 clone 关键字来拷贝。</p>
<h4 id="引用赋值"><a href="#引用赋值" class="headerlink" title="引用赋值"></a>引用赋值</h4><p>PHP 支持引用赋值，使用“$var = &amp;$othervar;”语法。引用赋值意味着两个变量指向了同一个数据，没有拷贝任何东西。</p>
<p>Example #1 引用赋值</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$a = <span class="number">3</span>;</div><div class="line">$b = &amp;$a; <span class="comment">// $b 是 $a 的引用</span></div><div class="line"></div><div class="line"><span class="keyword">print</span> <span class="string">"$a\n"</span>; <span class="comment">// 输出 3</span></div><div class="line"><span class="keyword">print</span> <span class="string">"$b\n"</span>; <span class="comment">// 输出 3</span></div><div class="line"></div><div class="line">$a = <span class="number">4</span>; <span class="comment">// 修改 $a</span></div><div class="line"></div><div class="line"><span class="keyword">print</span> <span class="string">"$a\n"</span>; <span class="comment">// 输出 4</span></div><div class="line"><span class="keyword">print</span> <span class="string">"$b\n"</span>; <span class="comment">// 也输出 4，因为 $b 是 $a 的引用，因此也被改变</span></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>自 PHP 5 起，new 运算符自动返回一个引用，因此再对 new 的结果进行引用赋值在 PHP 5.3 以及以后版本中会发出一条 E_DEPRECATED 错误信息，在之前版本会发出一条 E_STRICT 错误信息。</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">C</span> </span>&#123;&#125;</div><div class="line"></div><div class="line"><span class="comment">/* The following line generates the following error message:</span></div><div class="line"> * Deprecated: Assigning the return value of new by reference is deprecated in...</div><div class="line"> */</div><div class="line">$o = &amp;<span class="keyword">new</span> C;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="位运算符"><a href="#位运算符" class="headerlink" title="位运算符"></a>位运算符</h3><p>位运算符允许对整型数中指定的位进行求值和操作。<strong>将值变成二进制再求值</strong>。</p>
<p><img src="/uploads/位运算符.png" alt="位运算符"></p>
<p>位移在 PHP 中是数学运算。向任何方向移出去的位都被丢弃。左移时右侧以零填充，符号位被移走意味着正负号不被保留。右移时左侧以符号位填充，意味着正负号被保留。</p>
<p>要用括号确保想要的优先级。例如 $a &amp; $b == true 先进行比较再进行按位与；而 ($a &amp; $b) == true 则先进行按位与再进行比较。</p>
<h3 id="比较运算符"><a href="#比较运算符" class="headerlink" title="比较运算符"></a>比较运算符</h3><p>比较运算符，如同它们名称所暗示的，允许对两个值进行比较。</p>
<p><img src="/uploads/比较运算符.png" alt=""></p>
<p><strong>注意结合比较运算符 和 NULL 合并操作符</strong></p>
<p>如果比较一个数字和字符串或者比较涉及到数字内容的字符串，则字符串会被转换为数值并且比较按照数值来进行。此规则也适用于 switch 语句。当用 === 或 !== 进行比较时则不进行类型转换，因为此时类型和数值都要比对。</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">var_dump(<span class="number">0</span> == <span class="string">"a"</span>); <span class="comment">// 0 == 0 -&gt; true</span></div><div class="line">var_dump(<span class="string">"1"</span> == <span class="string">"01"</span>); <span class="comment">// 1 == 1 -&gt; true</span></div><div class="line">var_dump(<span class="string">"10"</span> == <span class="string">"1e1"</span>); <span class="comment">// 10 == 10 -&gt; true</span></div><div class="line">var_dump(<span class="number">100</span> == <span class="string">"1e2"</span>); <span class="comment">// 100 == 100 -&gt; true</span></div><div class="line"></div><div class="line"><span class="keyword">switch</span> (<span class="string">"a"</span>) &#123;</div><div class="line"><span class="keyword">case</span> <span class="number">0</span>:</div><div class="line">    <span class="keyword">echo</span> <span class="string">"0"</span>;</div><div class="line">    <span class="keyword">break</span>;</div><div class="line"><span class="keyword">case</span> <span class="string">"a"</span>: <span class="comment">// never reached because "a" is already matched with 0</span></div><div class="line">    <span class="keyword">echo</span> <span class="string">"a"</span>;</div><div class="line">    <span class="keyword">break</span>;</div><div class="line">&#125;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span>  </div><div class="line"><span class="comment">// Integers</span></div><div class="line"><span class="keyword">echo</span> <span class="number">1</span> &lt;=&gt; <span class="number">1</span>; <span class="comment">// 0</span></div><div class="line"><span class="keyword">echo</span> <span class="number">1</span> &lt;=&gt; <span class="number">2</span>; <span class="comment">// -1</span></div><div class="line"><span class="keyword">echo</span> <span class="number">2</span> &lt;=&gt; <span class="number">1</span>; <span class="comment">// 1</span></div><div class="line"> </div><div class="line"><span class="comment">// Floats</span></div><div class="line"><span class="keyword">echo</span> <span class="number">1.5</span> &lt;=&gt; <span class="number">1.5</span>; <span class="comment">// 0</span></div><div class="line"><span class="keyword">echo</span> <span class="number">1.5</span> &lt;=&gt; <span class="number">2.5</span>; <span class="comment">// -1</span></div><div class="line"><span class="keyword">echo</span> <span class="number">2.5</span> &lt;=&gt; <span class="number">1.5</span>; <span class="comment">// 1</span></div><div class="line"> </div><div class="line"><span class="comment">// Strings</span></div><div class="line"><span class="keyword">echo</span> <span class="string">"a"</span> &lt;=&gt; <span class="string">"a"</span>; <span class="comment">// 0</span></div><div class="line"><span class="keyword">echo</span> <span class="string">"a"</span> &lt;=&gt; <span class="string">"b"</span>; <span class="comment">// -1</span></div><div class="line"><span class="keyword">echo</span> <span class="string">"b"</span> &lt;=&gt; <span class="string">"a"</span>; <span class="comment">// 1</span></div><div class="line"> </div><div class="line"><span class="keyword">echo</span> <span class="string">"a"</span> &lt;=&gt; <span class="string">"aa"</span>; <span class="comment">// -1</span></div><div class="line"><span class="keyword">echo</span> <span class="string">"zz"</span> &lt;=&gt; <span class="string">"aa"</span>; <span class="comment">// 1</span></div><div class="line"> </div><div class="line"><span class="comment">// Arrays</span></div><div class="line"><span class="keyword">echo</span> [] &lt;=&gt; []; <span class="comment">// 0</span></div><div class="line"><span class="keyword">echo</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>] &lt;=&gt; [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]; <span class="comment">// 0</span></div><div class="line"><span class="keyword">echo</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>] &lt;=&gt; []; <span class="comment">// 1</span></div><div class="line"><span class="keyword">echo</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>] &lt;=&gt; [<span class="number">1</span>, <span class="number">2</span>, <span class="number">1</span>]; <span class="comment">// 1</span></div><div class="line"><span class="keyword">echo</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>] &lt;=&gt; [<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>]; <span class="comment">// -1</span></div><div class="line"> </div><div class="line"><span class="comment">// Objects</span></div><div class="line">$a = (object) [<span class="string">"a"</span> =&gt; <span class="string">"b"</span>]; </div><div class="line">$b = (object) [<span class="string">"a"</span> =&gt; <span class="string">"b"</span>]; </div><div class="line"><span class="keyword">echo</span> $a &lt;=&gt; $b; <span class="comment">// 0</span></div><div class="line"> </div><div class="line">$a = (object) [<span class="string">"a"</span> =&gt; <span class="string">"b"</span>]; </div><div class="line">$b = (object) [<span class="string">"a"</span> =&gt; <span class="string">"c"</span>]; </div><div class="line"><span class="keyword">echo</span> $a &lt;=&gt; $b; <span class="comment">// -1</span></div><div class="line"> </div><div class="line">$a = (object) [<span class="string">"a"</span> =&gt; <span class="string">"c"</span>]; </div><div class="line">$b = (object) [<span class="string">"a"</span> =&gt; <span class="string">"b"</span>]; </div><div class="line"><span class="keyword">echo</span> $a &lt;=&gt; $b; <span class="comment">// 1</span></div><div class="line"> </div><div class="line"><span class="comment">// only values are compared</span></div><div class="line">$a = (object) [<span class="string">"a"</span> =&gt; <span class="string">"b"</span>]; </div><div class="line">$b = (object) [<span class="string">"b"</span> =&gt; <span class="string">"b"</span>]; </div><div class="line"><span class="keyword">echo</span> $a &lt;=&gt; $b; <span class="comment">// 1</span></div><div class="line"></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>对于多种类型，比较运算符根据下表比较（按顺序）。</p>
<p><img src="/uploads/比较多种类型.png" alt="比较多种类型"></p>
<h4 id="三元运算符"><a href="#三元运算符" class="headerlink" title="三元运算符"></a>三元运算符</h4><p>另一个条件运算符是“?:”（或三元）运算符 。</p>
<p>Example #3 赋默认值</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"><span class="comment">// Example usage for: Ternary Operator</span></div><div class="line">$action = (<span class="keyword">empty</span>($_POST[<span class="string">'action'</span>])) ? <span class="string">'default'</span> : $_POST[<span class="string">'action'</span>];</div><div class="line"></div><div class="line"><span class="comment">// The above is identical to this if/else statement</span></div><div class="line"><span class="keyword">if</span> (<span class="keyword">empty</span>($_POST[<span class="string">'action'</span>])) &#123;</div><div class="line">    $action = <span class="string">'default'</span>;</div><div class="line">&#125; <span class="keyword">else</span> &#123;</div><div class="line">    $action = $_POST[<span class="string">'action'</span>];</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<p>表达式 (expr1) ? (expr2) : (expr3) 在 expr1 求值为 TRUE 时的值为 expr2，在 expr1 求值为 FALSE 时的值为 expr3。<br>自 PHP 5.3 起，可以省略三元运算符中间那部分。表达式 expr1 ?: expr3 在 expr1 求值为 TRUE 时返回 expr1，否则返回 expr3。</p>
<blockquote>
<p>Note: 注意三元运算符是个语句，因此其求值不是变量，而是语句的结果。如果想通过引用返回一个变量这点就很重要。在一个通过引用返回的函数中语句 return $var == 42 ? $a : $b; 将不起作用，以后的 PHP 版本会为此发出一条警告。</p>
</blockquote>
<h3 id="执行运算符"><a href="#执行运算符" class="headerlink" title="执行运算符"></a>执行运算符</h3><p>PHP 支持一个执行运算符：<strong>反引号（``）</strong>。注意这不是单引号！PHP 将尝试将反引号中的内容作为 shell 命令来执行，并将其输出信息返回（即，可以赋给一个变量而不是简单地丢弃到标准输出）。使用<code>反引号运算符“</code>”`的效果与函数 shell_exec() 相同。</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$output = `ls -al`;</div><div class="line"><span class="keyword">echo</span> <span class="string">"&lt;pre&gt;$output&lt;/pre&gt;"</span>;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="递增／递减运算符"><a href="#递增／递减运算符" class="headerlink" title="递增／递减运算符"></a>递增／递减运算符</h3><p>PHP 支持 C 风格的前／后递增与递减运算符。</p>
<blockquote>
<p>Note: 递增／递减运算符不影响布尔值。递减 NULL 值也没有效果，但是递增 NULL 的结果是 1。</p>
</blockquote>
<p><img src="/uploads/递增递减运算符.png" alt="递增递减运算符"></p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"><span class="keyword">echo</span> <span class="string">"&lt;h3&gt;Postincrement&lt;/h3&gt;"</span>;</div><div class="line">$a = <span class="number">5</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 5: "</span> . $a++ . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 6: "</span> . $a . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"&lt;h3&gt;Preincrement&lt;/h3&gt;"</span>;</div><div class="line">$a = <span class="number">5</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 6: "</span> . ++$a . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 6: "</span> . $a . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"&lt;h3&gt;Postdecrement&lt;/h3&gt;"</span>;</div><div class="line">$a = <span class="number">5</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 5: "</span> . $a-- . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 4: "</span> . $a . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"&lt;h3&gt;Predecrement&lt;/h3&gt;"</span>;</div><div class="line">$a = <span class="number">5</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 4: "</span> . --$a . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"Should be 4: "</span> . $a . <span class="string">"&lt;br /&gt;\n"</span>;</div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="逻辑运算符"><a href="#逻辑运算符" class="headerlink" title="逻辑运算符"></a>逻辑运算符</h3><p><img src="/uploads/逻辑运算符.png" alt="逻辑运算符"></p>
<p>“与”和“或”有两种不同形式运算符的原因是它们运算的优先级不同</p>
<p>Example #1 逻辑运算符示例</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"></div><div class="line"><span class="comment">// --------------------</span></div><div class="line"><span class="comment">// foo() 根本没机会被调用，被运算符“短路”了</span></div><div class="line"></div><div class="line">$a = (<span class="keyword">false</span> &amp;&amp; foo());</div><div class="line">$b = (<span class="keyword">true</span>  || foo());</div><div class="line">$c = (<span class="keyword">false</span> <span class="keyword">and</span> foo());</div><div class="line">$d = (<span class="keyword">true</span>  <span class="keyword">or</span>  foo());</div><div class="line"></div><div class="line"><span class="comment">// --------------------</span></div><div class="line"><span class="comment">// "||" 比 "or" 的优先级高</span></div><div class="line"></div><div class="line"><span class="comment">// 表达式 (false || true) 的结果被赋给 $e</span></div><div class="line"><span class="comment">// 等同于：($e = (false || true))</span></div><div class="line">$e = <span class="keyword">false</span> || <span class="keyword">true</span>;</div><div class="line"></div><div class="line"><span class="comment">// 常量 false 被赋给 $f，true 被忽略</span></div><div class="line"><span class="comment">// 等同于：(($f = false) or true)</span></div><div class="line">$f = <span class="keyword">false</span> <span class="keyword">or</span> <span class="keyword">true</span>;</div><div class="line"></div><div class="line">var_dump($e, $f);</div><div class="line"></div><div class="line"><span class="comment">// --------------------</span></div><div class="line"><span class="comment">// "&amp;&amp;" 比 "and" 的优先级高</span></div><div class="line"></div><div class="line"><span class="comment">// 表达式 (true &amp;&amp; false) 的结果被赋给 $g</span></div><div class="line"><span class="comment">// 等同于：($g = (true &amp;&amp; false))</span></div><div class="line">$g = <span class="keyword">true</span> &amp;&amp; <span class="keyword">false</span>;</div><div class="line"></div><div class="line"><span class="comment">// 常量 true 被赋给 $h，false 被忽略</span></div><div class="line"><span class="comment">// 等同于：(($h = true) and false)</span></div><div class="line">$h = <span class="keyword">true</span> <span class="keyword">and</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line">var_dump($g, $h);</div><div class="line"><span class="meta">?&gt;</span></div><div class="line"></div><div class="line">以上例程的输出类似于：</div><div class="line">bool(<span class="keyword">true</span>)</div><div class="line">bool(<span class="keyword">false</span>)</div><div class="line">bool(<span class="keyword">false</span>)</div><div class="line">bool(<span class="keyword">true</span>)</div></pre></td></tr></table></figure>
<h3 id="字符串运算符"><a href="#字符串运算符" class="headerlink" title="字符串运算符"></a>字符串运算符</h3><p>有两个字符串（string）运算符。第一个是连接运算符（“.”），它返回其左右参数连接后的字符串。第二个是连接赋值运算符（“.=”），它将右边参数附加到左边的参数之后。</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$a = <span class="string">"Hello "</span>;</div><div class="line">$b = $a . <span class="string">"World!"</span>; <span class="comment">// now $b contains "Hello World!"</span></div><div class="line"></div><div class="line">$a = <span class="string">"Hello "</span>;</div><div class="line">$a .= <span class="string">"World!"</span>;     <span class="comment">// now $a contains "Hello World!"</span></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="数组运算符"><a href="#数组运算符" class="headerlink" title="数组运算符"></a>数组运算符</h3><p><img src="/uploads/数组运算符.png" alt="数组运算符"></p>
<p><code>+</code>运算符把右边的数组元素附加到左边的数组后面，两个数组中都有的键名，则只用左边数组中的，右边的被忽略。</p>
<p>数组中的单元如果具有相同的键名和值则比较时相等。</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line">$a = <span class="keyword">array</span>(<span class="string">"apple"</span>, <span class="string">"banana"</span>);</div><div class="line">$b = <span class="keyword">array</span>(<span class="number">1</span> =&gt; <span class="string">"banana"</span>, <span class="string">"0"</span> =&gt; <span class="string">"apple"</span>);</div><div class="line"></div><div class="line">var_dump($a == $b); <span class="comment">// bool(true)</span></div><div class="line">var_dump($a === $b); <span class="comment">// bool(false)</span></div><div class="line"><span class="meta">?&gt;</span></div></pre></td></tr></table></figure>
<h3 id="类型运算符"><a href="#类型运算符" class="headerlink" title="类型运算符"></a>类型运算符</h3><p>instanceof 用于确定一个 PHP 变量是否属于某一类 class 的实例：</p>
<p>Example #1 对类使用 instanceof</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">MyClass</span></span></div><div class="line">&#123;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">NotMyClass</span></span></div><div class="line">&#123;</div><div class="line">&#125;</div><div class="line">$a = <span class="keyword">new</span> MyClass;</div><div class="line"></div><div class="line">var_dump($a <span class="keyword">instanceof</span> MyClass);</div><div class="line">var_dump($a <span class="keyword">instanceof</span> NotMyClass);</div><div class="line"><span class="meta">?&gt;</span></div><div class="line"></div><div class="line">上例会输出：</div><div class="line">bool(<span class="keyword">true</span>)</div><div class="line">bool(<span class="keyword">false</span>)</div></pre></td></tr></table></figure>
<p>instanceof　也可用来确定一个变量是不是继承自某一父类的子类的实例：</p>
<p>Example #2 对继承类使用 instanceof</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;?php</span></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">ParentClass</span></span></div><div class="line">&#123;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">MyClass</span> <span class="keyword">extends</span> <span class="title">ParentClass</span></span></div><div class="line">&#123;</div><div class="line">&#125;</div><div class="line"></div><div class="line">$a = <span class="keyword">new</span> MyClass;</div><div class="line"></div><div class="line">var_dump($a <span class="keyword">instanceof</span> MyClass);</div><div class="line">var_dump($a <span class="keyword">instanceof</span> ParentClass);</div><div class="line"><span class="meta">?&gt;</span></div><div class="line"></div><div class="line">上例会输出：</div><div class="line">bool(<span class="keyword">true</span>)</div><div class="line">bool(<span class="keyword">true</span>)</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/PHP/" rel="tag"># PHP</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/05/16/PHP变量和常量/" rel="next" title="PHP变量和常量">
                <i class="fa fa-chevron-left"></i> PHP变量和常量
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/05/17/PHP流程控制/" rel="prev" title="PHP流程控制">
                PHP流程控制 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://gasbylei.github.io/uploads/avatar.png"
               alt="Gasbylei" />
          <p class="site-author-name" itemprop="name">Gasbylei</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
           
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">17</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/Gasbylei" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#运算符优先级"><span class="nav-number">1.</span> <span class="nav-text">运算符优先级</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#算术运算符"><span class="nav-number">2.</span> <span class="nav-text">算术运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#赋值运算符"><span class="nav-number">3.</span> <span class="nav-text">赋值运算符</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#引用赋值"><span class="nav-number">3.1.</span> <span class="nav-text">引用赋值</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#位运算符"><span class="nav-number">4.</span> <span class="nav-text">位运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#比较运算符"><span class="nav-number">5.</span> <span class="nav-text">比较运算符</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#三元运算符"><span class="nav-number">5.1.</span> <span class="nav-text">三元运算符</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#执行运算符"><span class="nav-number">6.</span> <span class="nav-text">执行运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#递增／递减运算符"><span class="nav-number">7.</span> <span class="nav-text">递增／递减运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#逻辑运算符"><span class="nav-number">8.</span> <span class="nav-text">逻辑运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#字符串运算符"><span class="nav-number">9.</span> <span class="nav-text">字符串运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#数组运算符"><span class="nav-number">10.</span> <span class="nav-text">数组运算符</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#类型运算符"><span class="nav-number">11.</span> <span class="nav-text">类型运算符</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Gasbylei</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    
    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  

    <script type="text/javascript">
      var disqus_shortname = 'gatsbylei';
      var disqus_identifier = '2017/05/16/PHP运算符/';

      var disqus_title = "PHP运算符";


      function run_disqus_script(disqus_script) {
        var dsq = document.createElement('script');
        dsq.type = 'text/javascript';
        dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      }

      run_disqus_script('count.js');

      
        var disqus_config = function () {
            this.page.url = disqus_url;
            this.page.identifier = disqus_identifier;
            this.page.title = disqus_title;
        };
        run_disqus_script('embed.js');
      

    </script>
  










  
  

  

  

  

  


  

</body>
</html>
